//
// Created by madison on 2022/7/10.
//


#include <cstdio>
#include <cstddef>

/**
 * Definition for singly-linked list.
 */
struct ListNode {
    int val;
    ListNode *next;

    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    void deleteNode(ListNode *node) {
        node->val = node->next->val;
        node->next = node->next->next;
    }
};

int main() {
//    ListNode head = ListNode(4);
//    ListNode node1 = ListNode(5);
//    ListNode node2 = ListNode(1);
//    ListNode node3 = ListNode(9);
//    head.next = &node1;
//    node1.next = &node2;
//    node2.next = &node3;

    ListNode *head = new ListNode(4);
    ListNode *node1 = new ListNode(5);
    ListNode *node2 = new ListNode(1);
    ListNode *node3 = new ListNode(9);
    head->next = node1;
    node1->next = node2;
    node2->next = node3;

    printf("%d\n", head->next->next->val);

    Solution solution;
    solution.deleteNode(node1);

    ListNode *temp = head;
    while (temp != nullptr) {
        printf("%d\t", temp->val);
        temp = temp->next;
    }
    return 0;
}